﻿// <copyright file="SensorReceiverProxy.cs" company="Hallvard Korsgaard">
//  Microsoft Public License (Ms-PL). See license details here: http://enoceannet.codeplex.com/license
// </copyright>
// <author>Hallvard Korsgaard</author>

namespace EnOceanService
{
  using System.Collections.Generic;
  using System.ServiceModel;
  using ServiceContract;

  /// <summary>
  /// WCF proxy for the IEnOceanReceiver service.
  /// </summary>
  internal class SensorReceiverProxy : ClientBase<IEnOceanReceiver>, IEnOceanReceiver
  {
    /// <summary>
    /// Initializes a new instance of the SensorReceiverProxy class.
    /// </summary>
    /// <param name="remoteAddress">The addres of the service.</param>
    internal SensorReceiverProxy(EndpointAddress remoteAddress)
      : base(new BasicHttpBinding(), remoteAddress)
    {
    }

    /// <summary>
    /// The service should return a list of sensor id's that the service wants updates from, or NULL to receive updates from any sensor.
    /// </summary>
    /// <returns>A list of sensor id's that the service wants updates from, or NULL to receive updates from any sensor.</returns>
    public IEnumerable<long> Subscriptions()
    {
      return this.Channel.Subscriptions();
    }

    /// <summary>
    /// This method is called when a sensor is triggered.
    /// </summary>
    /// <param name="sensorData">The sensor data.</param>
    public void SensorUpdated(ServiceContract.SensorData sensorData)
    {
      this.Channel.SensorUpdated(sensorData);
    }
  }
}
